package com.th.apicenter.tools;

import lombok.Data;
import org.springframework.stereotype.Component;

@Data
@Component
public class ThResult {
    private int resultCode;

    private String msg;

    private long time;

    private Object data;

    public static ThResult success(Object object) {
        ThResult thResult = new ThResult();
        long timestamp = System.currentTimeMillis();
        thResult.setResultCode(200);
        thResult.setMsg("success");
        thResult.setData(object);
        thResult.setTime(timestamp);
        return thResult;
    }

    public static ThResult error(Object object) {
        ThResult thResult = new ThResult();
        long timestamp = System.currentTimeMillis();
        thResult.setResultCode(500);
        thResult.setMsg("服务器繁忙！");
        thResult.setData(object);
        thResult.setTime(timestamp);
        return thResult;
    }

}
